<?php

namespace App\Http\Controllers;

use App\Hydrators\Hydrator;
use Dingo\Api\Routing\Helpers;
use Illuminate\Support\Facades\DB;
use Incoming\Processor;
use Laravel\Lumen\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use Helpers;

    public function hydrate($model, Hydrator $hydrator)
    {
        $incoming = new Processor();
        DB::beginTransaction();
        $result = $incoming->process(
            app('request')->all(),
            $model,
            $hydrator
        );
        DB::commit();
        return $result;
    }
}
